package javaMultiThread;
/**
 * 
 * @author jieji
 *
 */
/**
 * wait(),notify()调用此方法必须活得该对象的对象锁,即在同步代码块中
 * 
 * 调用notify线程会随机挑一个正在等等的次this的方法
 * 
 * 调用wait锁自动释放
 * 调用notify只有执行完同步代码块才释放锁
 * 
 *
 */
/**
 * wait(long)等待这么多毫秒,如果没有notify则自动唤醒
 *
 */
/**
 * join方法把当前线程挂起,等待当前线程开启thread结束后再执行后面的代码
 * join(long)和sleep(long)方法差不多,但join释放锁,sleep不释放锁
 */
public class Thread3 {

	public static void main(String[] args) {
		t1();
	}
	public static void t1(){
		Thread3A t3a=new Thread3A();
		t3a.start();
		try {
			t3a.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("main end");
	}

}
class Thread3A extends Thread{

	@Override
	public void run() {
		super.run();
		System.out.println("start");
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("end");
	}
}
